﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.User>" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	创建用户
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>创建用户</h2>

    <p class="sys_create_btn">
        <%= Html.ActionLink("返回用户列表", "Index") %>
    </p>

    <% using (Html.BeginForm()) {%>
        <%= Html.ValidationSummary(true) %>

        <table cellpadding="4" cellspacing="0" class="com_detail_table" style="width:756px;">
            <tr>
                <th colspan="2">填写用户属性<%= Html.HiddenFor(model => model.Id) %></th>
            </tr>

            <tr>
                <td class="lab" style="width:110px;">所属公司：</td>
                <td>
                    <%= Html.DropDownList("FactoryId", ViewData["factories"] as List<SelectListItem>, "请选择公司")%>
                    <%= Html.ValidationMessageFor(model => model.FactoryId) %>
                </td>
            </tr>
            
            <tr>
                <td class="lab">用户角色：</td>
                <td>
                    <%= Html.DropDownList("RoleId", ViewData["roles"] as List<SelectListItem>, "请选择角色")%>
                    <%= Html.ValidationMessageFor(model => model.RoleId) %>
                </td>
            </tr>

            <tr>
                <td class="lab">登录帐号：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.Name) %>
                    <%= Html.ValidationMessageFor(model => model.Name) %>
                </td>
            </tr>

            <tr>
                <td class="lab">用户名称：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.RealName) %>
                    <%= Html.ValidationMessageFor(model => model.RealName) %>
                </td>
            </tr>

            <tr>
                <td class="lab">用户密码：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.Password)%>
                    <%= Html.ValidationMessageFor(model => model.Password) %>
                    <input type="button" value="生成随机密码" style="margin-left:10px" onclick="getRandomPwd();" />
                </td>
            </tr>

            <tr>
                <td class="lab">固定电话：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.Phone) %>
                    <%= Html.ValidationMessageFor(model => model.Phone) %>
                </td>
            </tr>

            <tr>
                <td class="lab">手机号码：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.Mobile) %>
                    <%= Html.ValidationMessageFor(model => model.Mobile) %>
                </td>
            </tr>

            <tr>
                <td class="lab">电子邮箱：</td>
                <td>
                    <%= Html.TextBoxFor(model => model.Email) %>
                <%= Html.ValidationMessageFor(model => model.Email) %>
                </td>
            </tr>
                
                
        </table>
        
        <div class="submit_btn_area" style="margin-left:122px;">
            <input type="submit" value="创建用户" />
        </div>

    <% } %>

    <script type="text/javascript" language="javascript">
        function getRandomPwd()
        {
            var pwd = "";
            for (i = 0; i < 6; i++)
            {
                pwd = pwd + Math.floor(Math.random() * 10)+"";
            }
            document.getElementById("Password").value = pwd;
        }
    </script>

</asp:Content>

